using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace Ideopuzzle
{
    public class LogoScreen : DrawableGameComponent
    {
        SpriteBatch sprite_batch;

        Texture2D logo;
        Rectangle texture_rectangle;
        float alpha;

        #region Constructors

        public LogoScreen(Game game)
            : base(game)
        {
            alpha = 0.0f;
        }

        #endregion

        public override void Initialize()
        {
            sprite_batch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));

            base.Initialize();
        }

        protected override void LoadContent()
        {
            logo = Game.Content.Load<Texture2D>("Textures/Shared/vst_logo");
            texture_rectangle = new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - logo.Width / 2,
                Game.GraphicsDevice.Viewport.Height / 2 - logo.Height / 2, logo.Width, logo.Height);

            base.LoadContent();
        }

        public override void Update(GameTime gameTime)
        {
            float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            alpha += (dt * 2.0f);

            if (alpha > 2.0f) ScreenManager.SelectMainMenu(Game);

            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            sprite_batch.Begin();

            sprite_batch.Draw(logo, texture_rectangle, Color.White * alpha);

            sprite_batch.End();

            base.Draw(gameTime);
        }
    }
}
